import React from 'react';
// import logo from './logo.svg';
import Grandepa from './component/Grandepa'
import Mycontext from'./Mycontext'
//结构出Provider组件，用来提供上下文数据
const {Provider}=Mycontext
class App extends React.Component{
  constructor(props){
    super(props);
    this.state={
      msg:'hello',
      goods:{
        lists:[
          {id:'001',name:'🍌'},
          {id:'002',name:'🍊'},
          {id:'003',name:'🐱'},
          {id:'004',name:'🦁'}
        ]
      }
    }
  }
  change(){
    this.setState({
      msg:'welcome to Wuhan'
    })
  }
  

  testMethod(argv){
    console.log(argv,this)
  }
  render() {
    let state=this.state;
    state.testMethod=(argv)=>{this.testMethod(argv)}
    return (
      <div className="App">
        {state.msg}
        <button onClick={e=>this.change()}>修改</button>
      <Provider value={state}>
         <Grandepa />
      </Provider>
    

      </div>
    );
  }
  
}

export default App;
